home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / FCLOSALL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  660 b   |  22 lines

  1. /* fclosall.c  --- p 404 */
  2. #include <stdio.h>
  3. main()
  4. {
  5.      int i;
  6.         /* Try opening 20 temporary files -- we'll just throw
  7.          * away the returned pointers because we are not going
  8.          * to use these files. The file open will fail after 15
  9.          * files are opened. So the number of closed files
  10.          * should be 15. */
  11.      for (i=0; i < 20; i++)
  12.      {
  13.         if (tmpfile() == NULL)
  14.             printf ("Error opening file # %d\n", i);
  15.         else
  16.             printf ("Temporary file #%d opened\n", i);
  17.      }
  18.             /* Now closed all the files and inform user how many were
  19.                      * closed */
  20.      i = fcloseall();
  21.      printf("%d files were closed -- should be 15\n", i);
  22. }